package com.example.base.system.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.base.limit.IPRateLimit;
import java.util.List;
import com.example.base.excetion.GlobalExcetion;
import com.example.base.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.example.base.config.PageData;
import com.example.base.system.service.SysJobRecordService;
import com.example.base.system.domain.SysJobRecord;
import java.io.Serializable;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author X.I.O
 * @since 2024-02-20
 */

@RestController
@Api(tags = {"的服务类"})
@RequestMapping("/sys-job-record")
public class SysJobRecordController  {

        @Autowired
        private SysJobRecordService sysJobRecordService;


        @GetMapping("/getall")
        @IPRateLimit(name = "SysJobRecord-getall",msg = "系统检测到ip异常访问行为，已暂停访问")
        @ApiOperation(value = "的获取全部接口",notes = "的获取全部接口")
        public JSONObject findAll() throws GlobalExcetion {
                List<SysJobRecord> list= sysJobRecordService.list();
                return Result.successInfo(list);
        }

        @GetMapping("/{id}")
        @IPRateLimit(name = "SysJobRecord-getid",msg = "系统检测到ip异常访问行为，已暂停访问")
        @ApiOperation(value = "的获取一个接口",notes = "的获取一个接口")
        public JSONObject findOne(@PathVariable("id") Serializable id) throws GlobalExcetion {
                SysJobRecord data= sysJobRecordService.getById(id);
                return Result.successInfo(data);
        }

        @GetMapping("/page")
        @IPRateLimit(name = "SysJobRecord-page",msg = "系统检测到ip异常访问行为，已暂停访问")
        @ApiOperation(value = "的分页接口",notes = "的分页接口")
        public JSONObject findPage(@RequestParam("id")Serializable id,
                                   @RequestParam(value = "page",defaultValue = "1") Integer page,
                                   @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize) throws GlobalExcetion {
                IPage<SysJobRecord> data=sysJobRecordService.page(id,page,pageSize);
                PageData pageData=new PageData(data.getTotal(),page,pageSize,data.getRecords());
                return Result.successInfo(pageData);
        }
}

